1484241967 by Unknown

1484241967 by Unknown

Author:Unknown
Language: eng
Format: epub
Published: 2018-11-30T07:01:40+00:00


Chapter 6 Week 6: C++

-- Looking for pthread_create in pthread - found

-- Found Threads: TRUE

-- Found OpenSSL: /usr/lib/libcrypto.so (found version

"1.1.0i")

-- Boost version: 1.67.0

-- Found the following Boost libraries:

-- system

-- Found CURL: /usr/lib/libcurl.so (found version "7.61.1")

-- Configuring done

-- Generating done

-- Build files have been written to: /home/niko/Dropbox/BOOKS2/

APRESS/06-cplusplus/samplecmake

If you are writing code from Visual Studio Code again, there is a

specific and dedicated plug-in, created by Microsoft, that you can install (Figure 6-1).

Figure 6-1. C/C++ plug-in for Visual Studio Code

116

Chapter 6 Week 6: C++

With the plug-in installed, you can start typing C++ code and your first C++ program of the day.

Here is a list of reminders before proceeding to look at the code:

• #include is used to include namespaces

• Using namespace will prevent you from having to

insert the namespace in front of each symbol of given

namespaces, thus, std::string will become string,

for example.

• intmain(intargc, char* argv[]) is the main entry

point, and you can retrieve the number of args, as well

as an array of parameters. Note that the first parameter

is at index 0 and is the command name itself. Here, it

will be samplecmake, as it was defined in the project

metadata file, CMakeLists.txt.

• auto url means that we do not specify the type of the

variable ourselves; the compiler does it. Here, it will

actually be a char*, which is a pointer to an array of

characters.

• We will actually download the file using a system

command, curl (which should be installed on your

machine).

• The shell command curl is called using the system

function, with url as the parameter to the curl

command.

This now gives the slightly readable code snippet following, which should be saved in a file named main.cpp.

#include <string>

using namespace std;

117



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.